package com.joe.codemother.entity.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

@Getter
public enum UserRoleEnums {

    User("user","user"),
    Admin("admin","admin");

    private final String roleName;

    private final String roleValue;

    UserRoleEnums(String roleName, String roleValue) {
        this.roleName = roleName;
        this.roleValue = roleValue;
    }

    public static UserRoleEnums getEnumByValue(String value) {
        if(StringUtils.isEmpty(value)){
            return null;
        }
        for(UserRoleEnums roleEnum : UserRoleEnums.values()){
            if(roleEnum.getRoleValue().equals(value)){
                return roleEnum;
            }
        }
        return null;
    }


}
